<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta name="author" content="Kodinger">
	<meta name="viewport" content="width=device-width,initial-scale=1">
	<title>欢迎登录</title>
	<link rel="stylesheet" href="${base}/css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="${base}/css/login.css">
</head>

<body class="my-login-page">
	<section class="h-100">
		<div class="container h-100">
			<div class="row justify-content-md-center h-100">
				<div class="card-wrapper">
					<div class="brand">
						<img src="${base}/img/logo.jpg" alt="logo">
					</div>
					<div class="card fat">
						<div class="card-body">
							<h4 class="card-title">Login</h4>
							<form class="my-login-validation" novalidate="">
								<div class="form-group">
									<label for="username">用户名</label>
									<input id="username" class="form-control" name="username" value="" required autofocus>
									<div class="invalid-feedback">
										请输入用户名
									</div>
								</div>

								<div class="form-group">
									<label for="password">密码
										<a href="forgot.html" class="float-right">
											忘记密码？
										</a>
									</label>
									<input id="password" type="password" class="form-control" name="password" required data-eye>
								    <div class="invalid-feedback">
								    	请输入密码
							    	</div>
								</div>

								<div class="form-group">
									<div class="custom-checkbox custom-control">
										<input type="checkbox" name="remember" id="remember" class="custom-control-input">
										<label for="remember" class="custom-control-label">记住我</label>
									</div>
								</div>

								<div class="form-group m-0">
									<button type="button" class="btn btn-primary btn-block" id="login-btn">
										登  录
									</button>
								</div>
								<div class="mt-4 text-center">
									Don't have an account? <a href="register.html">新建一个用户</a>
								</div>
							</form>
						</div>
					</div>
					<div class="footer">
						Copyright &copy; 2017 &mdash; Your Company 
					</div>
				</div>
			</div>
		</div>
	</section>

	<script src="${base}/js/jquery-3.3.1.slim.min.js"></script>
	<script src="${base}/js/jquery.min.js"></script>
	<script src="${base}/js/popper.min.js"></script>
	<script src="${base}/js/bootstrap.min.js"></script>
<script>
	var base = "${base}";

	$("#login-btn").click(function () {
		$.ajax({
			url: base + "/doLogin",
			method: "post",
			dataType:"json",
			data: {"username": $("#username").val() , "password": $("#password").val()},
			success: function (rep) {
				console.log(rep);
				if (rep.success){
					window.location.href=base + "/index";
				}else {
					alert(rep.msg);
				}
			}
		})
	})
</script>
</body>
</html>
